import Controller.User;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;

public class Start {
    public static void main(String[] args) {
        BeanFactory beanFactory=new XmlBeanFactory( new ClassPathResource("spring-config.xml"));
        User user=beanFactory.getBean(User.class);
        user.hi();
    }
    public static void main1(String[] args) {
        //得到Spring对象的上下文
        ApplicationContext context=new ClassPathXmlApplicationContext("spring-config.xml");
        //从Spring容器中获取bean对象
        User user=(User) context.getBean("user", User.class);
        user.hi();

    }
}
